<?php
    /* 2020.6.5
     * 书评回复方法
     * @author huangchuting
     *  */
    require_once 'config.php';
    
    /* 根据书评统计回复数量
     * @param reviewId
     * @return param
     *  */
     function replyCountRId($reviewId){
         $sqlGet="SELECT count(*) as nums FROM reply WHERE reviewId='$reviewId'";
         $result=getQuery($sqlGet);
         $value = 0;
         if(count($result)>0) {//判断是否成功执行
             $value = $result[0]["nums"];
         }
         return $value;
     }
     
     /*  增加评论
      * @param reviewId uId content
      * @return  Primary_key_id
      *  */
     function addReply($reviewId,$uId,$content){
         $sqlAdd="INSERT INTO reply(replyId,content,replytime,reviewId,uId)
                   VALUES ('','$content',now(),'$reviewId','$uId')";
         $result=add($sqlAdd);
         return $result;
     }
     
     /* 根据书评编号查找评论
      * @param reviewId
      * @return array*rows
      *  */
     
     function getReplyRId($reviewId){
         $sqlGet="SELECT * FROM reply WHERE reviewId='$reviewId'";
         $result=getQuery($sqlGet);
         return $result;
     }
     
     /* 删除书评的评论
      * @return row
      * */
     function deleteReply($replyId){
         $sqlDel="DELETE FROM reply WHERE replyId='$replyId'";
         $result=delete($sqlDel);
         return $result;
     }
     
     //根据用户Id查找评论
     function findreply($uId){
         $sqlGet="SELECT * FROM reply WHERE uId='$uId'";
         $result=getQuery($sqlGet);
         return $result;
     }
     
   
?>